// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "WorldEntityPart.h"
#include "WorldContactPoint.h"

class FWorldRoad;
class FWorldController;

/**
 * An entity of a junction/controller.
 */
class FWorldJunctionController : public FWorldEntityPart
{

public:

	using Ptr = std::shared_ptr<FWorldJunctionController>;
	using Super = FWorldEntityPart;

	FWorldEntityReference< FWorldController >		ID;
	FWorldEntityProperty< std::string >				Type;
	FWorldEntityProperty< std::uint32_t >			Sequence;

public:

	FWorldJunctionController();
	FWorldJunctionController(FWorldEntityPart* parent, const pugi::xml_node& elem);
	~FWorldJunctionController() override;

	void Resolve(FWorldEntityReferencing& referencing) override;

	WORLD_ENTITY_META_DECLARE(FWorldJunctionController)

};

/**
 * An entity of a junction/priority.
 */
class FWorldJunctionPriority : public FWorldEntityPart
{

public:

	using Ptr = std::shared_ptr<FWorldJunctionPriority>;
	using Super = FWorldEntityPart;

	FWorldEntityReference< FWorldRoad >		High;
	FWorldEntityReference< FWorldRoad >		Low;

public:

	FWorldJunctionPriority();
	FWorldJunctionPriority(FWorldEntityPart* parent, const pugi::xml_node& elem);
	~FWorldJunctionPriority() override;

	void Resolve(FWorldEntityReferencing& referencing) override;

	WORLD_ENTITY_META_DECLARE(FWorldJunctionPriority)

};

/**
 * An entity of a junction/connection/laneLink.
 */
class FWorldJunctionLaneLink : public FWorldEntityPart
{

public:

	using Ptr = std::shared_ptr<FWorldJunctionLaneLink>;
	using Super = FWorldEntityPart;

	FWorldEntityProperty< int >		From;
	FWorldEntityProperty< int >		To;

public:

	FWorldJunctionLaneLink();
	FWorldJunctionLaneLink(FWorldEntityPart* parent, const pugi::xml_node& elem);
	~FWorldJunctionLaneLink() override;

	WORLD_ENTITY_META_DECLARE(FWorldJunctionLaneLink)

};

/**
 * An entity of a junction/connection.
 */
class FWorldJunctionConnection : public FWorldEntityPart
{

public:

	using Ptr = std::shared_ptr<FWorldJunctionConnection>;
	using Super = FWorldEntityPart;

	FWorldEntityProperty< std::string >										ID;
	FWorldEntityReference< FWorldRoad >										IncomingRoad;
	FWorldEntityReference< FWorldRoad >										ConnectingRoad;
	FWorldEntityProperty< FWorldContactPoint >								ContactPoint;
	FWorldEntityPartArrayReference< FWorldJunctionLaneLink, 0, INT_MAX >	LaneLink;

public:

	FWorldJunctionConnection();
	FWorldJunctionConnection(FWorldEntityPart* parent, const pugi::xml_node& elem);
	~FWorldJunctionConnection() override;

	void Resolve(FWorldEntityReferencing& referencing) override;

	WORLD_ENTITY_META_DECLARE(FWorldJunctionConnection)

};
